<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>百慧wms仓库</title>
    <link href="../layui/css/layui.css" rel="stylesheet">
</head>
<body>

<div class="layui-fluid">

    <table class="layui-table" lay-skin="line">
        <tbody></tbody>
    </table>

</div>

<script src="../layui/layui.js"></script>
<script>
    layui.use(["jquery","layer"],function (){
        let $ = layui.jquery;
        let layer = layui.layer;
        //截取参数
        let url = location.href;
        url = url.substring(url.lastIndexOf("?")+1,url.length);
        let userId=url.split("=")[1];
        $.getJSON("/getUserDetail",{userId:userId},function (d){
            if (d.code===0){
                //展示数据
                let s="";
                $.each(d.obj,function (key,val){
                    if(key=="userId"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">用户编号</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="userName"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">用户名称</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="userEmail"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">邮箱</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="userTel"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">手机号</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="userNick"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">用户昵称</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="password"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">密码</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="createTime"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">创建时间</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="updateTime"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">更新时间</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="salt"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">盐值</td>\n" +
                            "                <td style=\"width: 75%;\">"+val+"</td>\n" +
                            "            </tr>";
                    }else if(key=="isDelete"){
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">是否有效</td>\n" +
                            "                <td style=\"width: 75%;\"> "+(val==1?'<span class="layui-badge layui-bg-blue">有效</span>':'<span class="layui-badge layui-bg-orange">无效</span>')+" </td>\n" +
                            "            </tr>";
                    }else if(key=="departments"){
                        let ds = "";
                        if(val!=null && val!="" && val.length>0){
                            for (let i = 0; i < val.length; i++) {
                                ds+=val[i].deptName+"&nbsp;&nbsp;";
                            }
                        }
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">部门</td>\n" +
                            "                <td style=\"width: 75%;\">"+ds+"</td>\n" +
                            "            </tr>";
                    }else if(key=="roles"){
                        let rs = "";
                        if(val!=null && val!="" && val.length>0){
                            for (let i = 0; i < val.length; i++) {
                                rs+=val[i].roleName+"&nbsp;&nbsp;";
                            }
                        }
                        s+="<tr>\n" +
                            "                <td style=\"width: 25%;\">角色</td>\n" +
                            "                <td style=\"width: 75%;\">"+rs+"</td>\n" +
                            "            </tr>";
                    }

                });
                //展示到指定位置
                $("tbody").html(s);
            }else {
                layer.msg(d.msg);
            }
        });
    });

</script>
</body>
</html>